<template>
    <el-menu
      :default-active="defActive"
      class="el-menu-vertical-demo"
      style="height: 600px;"
      router

    >
      <el-menu-item index="/home/user" >
        <i class="el-icon-user"></i>
        <span slot="title">我的账号</span>
      </el-menu-item>
      <el-menu-item index="/home/user/pwd">
        <i class="el-icon-key"></i>
        <span slot="title">修改密码</span>
      </el-menu-item>
    </el-menu>
  </template>
  
  <script>
  export default {
    name: 'DwUserMenu',
    data () {
      return {
        defActive: '/home/user'
      }
    },
    mounted () {
      this.setDefActive()
    },
    watch: {
      $route: function (to, from) {
        this.setDefActive()
      }
    },
    methods: {

      setDefActive () {
        const fullPath = this.$route.fullPath

        if (fullPath.indexOf('/home/user/pwd') >= 0) {

          this.defActive = '/home/user/pwd'
        }else if (fullPath.indexOf('/home/user') >= 0) {
            this.defActive = '/home/user'

        }
          
      }
    }
  }
  </script>
  
  <style scoped>
  
  </style>
  